@extends('admin.app')

@section('breadcrumb')
    <div class="bg-light lter b-b wrapper-md">
        <ol class="breadcrumb bg-light lter m-n no-padder">
            <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
            <li>业务管理</li>
            <li class="active">用户管理</li>
        </ol>
    </div>
@endsection

@section('content')
    <div class="panel panel-default">
        <div class="panel-heading font-bold">
            用户列表列表
        </div>
        <div class="row wrapper">
            <div class="col-sm-8">
                <form class="form-horizontal" method="get"
                      action="/admin/business/users">
                    <div class="row">
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">用户身份标识:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="姓名 用户名 手机 邮箱" name="userKey"
                                           value="{{ $query['userKey'] }}"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">身份证:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="身份证号码" name="id_card"
                                           value="{{ $query['id_card'] }}"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-10">
                            <div class="form-group">
                                <label class="control-label col-sm-2">激活时间:</label>
                                <div class="col-sm-4">
                                    
                                    <input type="text" class="form-control datetimepicker" name="p_start_at"
                                           value="" placeholder="请选择开始时间">

                                </div>
                                <div class="col-sm-4">
                                    
                                    <input type="text" class="form-control datetimepicker" name="p_end_at"
                                           value="" placeholder="请选择结束时间">

                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">支付账户激活:</label>
                                <div class="col-sm-8">
                                    <select name="is_set_pay_password" class="form-control">
                                        <option value="">无</option>
                                        <option value="1" {{ $query['is_set_pay_password']==1?'selected=selected':'' }}>是</option>
                                        <option value="0" {{ $query['is_set_pay_password']==='0'?'selected=selected':'' }}>否</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">是否绑定手机:</label>
                                <div class="col-sm-8">
                                    <select name="is_set_phone" class="form-control">
                                        <option value="">无</option>
                                        <option value="1" {{ $query['is_set_phone']==1?'selected=selected':'' }}>是</option>
                                        <option value="0" {{ $query['is_set_phone']==='0'?'selected=selected':'' }}>否</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">是否绑定银行卡:</label>
                                <div class="col-sm-8">
                                    <select name="is_set_bankcard" class="form-control">
                                        <option value="">无</option>
                                        <option value="1" {{ $query['is_set_bankcard']==1?'selected=selected':'' }}>是</option>
                                        <option value="0" {{ $query['is_set_bankcard']==='0'?'selected=selected':'' }}>否</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-1 text-left">
            <span class="input-group-btn">
              <button class="btn btn-sm btn-default" type="submit">查询</button>
            </span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-4 text-right text-center-xs">
                <a class="btn m-b-xs btn-sm btn-default btn-addon"
                   href="{{ admin_action('Business\UsersController@create') }}">
                    <i class="fa fa-plus"></i>新增一个用户
                </a>
                    <a href="{{ admin_action('Business\UsersController@index',['download'=>'download','userKey'=>$query['userKey'],'is_set_pay_password'=>$query['is_set_pay_password']]) }}" class="btn btn-sm btn-primary btn-addon">
                        <i class="fa fa-download"></i>excel导出查询结果
                    </a>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                <tr>
                    <th>用户ID</th>
                    <th>用户名</th>
                    <th>真实姓名</th>
                    <th>是否实名</th>
                    <th>手机号码</th>
                    <th>认证手机</th>
                    <th>认证邮箱</th>
                    <th>是否绑卡</th>
                    <th>支付账户激活</th>
                    <th>注册时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @forelse ($users as $user)
                    <tr>
                        <td>{{ $user->id }}</td>
                        <td>{{ $user->username??"--" }}</td>
                        <td>{{ empty($user->name)?"--":$user->name }}</td>
                        <td>{{ $user->name_verified==0?'N':'Y' }}</td>
                        <td>{{ $user->phone_number??"--"}}</td>
                        <td>{{ $user->phone_number_verified==0?'N':'Y' }}</td>
                        <td>{{ $user->email_verified==0?'N':'Y'}}</td>
                        <td>{{ empty($user->bank_card_number)?'N':'Y'}}</td>
                        <td>{{ $user->is_set_pay_password ? 'Y' : 'N' }}</td>
                        <td>{{ $user->created_at }}</td>
                        <td>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\UsersController@show', [$user]) }}"
                               data-toggle="tooltip" title="预览该用户">
                                <i class="fa fa-info"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\UsersController@edit', [$user]) }}"
                               data-toggle="tooltip" title="编辑该用户">
                                <i class="fa fa-pencil"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                                   href="{{ admin_action('Business\UsersController@setRealName', [$user]) }}"
                                   data-toggle="tooltip" title="用户实名认证">
                                <i class="fa fa-user"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                                   href="{{ admin_action('Business\UsersController@modifyPhoneNumber', [$user]) }}"
                                   data-toggle="tooltip" title="强制变更用户手机">
                                <i class="fa fa-phone"></i>
                            </a>
                            <form class="inline"
                                  action="{{ admin_action('Business\UsersController@unlock', [$user]) }}"
                                  method="post">
                                {{ csrf_field() }}
                                <button type="button" data-swal-role="delete-confirm" data-swal-title="温馨提示"
                                        data-swal-text="将会解除用户 <{{ empty($user->userInfo->name)?$user->username:$user->userInfo->name }}> 的锁定状态"
                                        class="btn btn-xs btn-primary" data-toggle="tooltip" title="解除锁定">
                                    <i class="fa fa-unlock"></i>
                                </button>
                            </form>
                            <form class="inline"
                                  action="{{ admin_action('Business\UsersController@destroy', [$user]) }}"
                                  method="post">
                                {{ csrf_field() }}
                                {{ method_field('DELETE') }}
                                <button type="button" data-swal-role="delete-confirm" data-swal-title="温馨提示"
                                        data-swal-text="您将删除用户 <{{ empty($user->userInfo->name)?$user->username:$user->userInfo->name }}>   "
                                        class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除用户">
                                    <i class="fa fa-trash-o"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="3" class="text-center">没有找到用户记录</td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="panel-footer">
            <div class="row">
                <div class="col-sm-12 text-right text-center-xs">
                    {!! $links !!}
                </div>
            </div>
        </div>
    </div>
@endsection